/*	******************************************
	File:		StateVideoTest.cpp
	Author:		Adnan Srna, Peter Kober, Ivo Havranek
	Purpose:	AugmentedReality 2
	(up)Date:	March/April 2010
	Descr.:		demo game for our face tracking 
	Origin:		Salzburg University of Applied Science
	******************************************	*/

#include "StateVideoTest.h"
#include "StateSoundTest.h"
#include "StateGame.h"

StateVideoTest::StateVideoTest(){
	ofAddListener(ofEvents.keyPressed, this, &StateVideoTest::keyPressed);
}

StateVideoTest::~StateVideoTest(){
	ofRemoveListener(ofEvents.keyPressed, this, &StateVideoTest::keyPressed);	
}

void StateVideoTest::setup(StateManager* _manager){
	manager = _manager;
	guiText.loadFont("calibri.ttf", 12, false, false, true);
	faceTool.setup();
}

void StateVideoTest::update(){
	ofBackground(10, 10, 10);
	faceTool.update();
}


void StateVideoTest::draw(){
	faceTool.draw();
	drawGUI(faceTool._pos.x,faceTool._pos.y);
}


void StateVideoTest::keyPressed(ofKeyEventArgs& arg)
{
	switch(arg.key){
		case '1':
			changeState(manager, new StateSoundTest());
			break;
		case '3':
			changeState(manager, new StateGame());
			break;		
		case 'q':
			ofAppGlutWindow::exitApp();
			break;
	}
}

void StateVideoTest::drawGUI(float x, float y){
	ofSetColor(255, 255, 255);
	char posX[255], posY[255];

	guiText.drawString("mmt08/HavI,KobP,SrnA - Demo for Face Tracking -", 50, 15);
	guiText.drawString("Face Position: ", 50, ofGetHeight()-15);
	guiText.drawString("press [1]SoundTest, [3]Game", 50, 40);
	
	sprintf(posX, " X: %f", x);
	guiText.drawString(posX, 150, ofGetHeight()-15);

	sprintf(posY, " Y: %f", y);
	guiText.drawString(posY, 260, ofGetHeight()-15);
}
